Functions | |
| OSL_PALETTE * | oslCreatePaletteEx (int size, int location, short pixelFormat) |
| OSL_PALETTE * | oslCreatePalette (int size, short pixelFormat) |
| OSL_PALETTE * | oslCreatePaletteFrom (void *data, int size, short pixelFormat) |
| void | oslDeletePalette (OSL_PALETTE *p) |
| int | oslGetPaletteColor (OSL_PALETTE *p, int index) |
| void | oslUncachePalette (OSL_PALETTE *pal) |
| OSL_PALETTE* oslCreatePaletteEx | ( | int | size, | |
| int | location, | |||
| short | pixelFormat | |||
| ) |
Creates a new (empty) palette with the specified pixelFormat.
| size | Number of colors of the palette. | |
| location | Location where to put the palette. Always put it in RAM for now (OSL_IN_RAM). | |
| pixelFormat | Pixel format of each palette entry. It should always be OSL_PF_8888 as palettes are rather small in size. |
OSL_IMAGE *img = oslCreateImage(32, 32, OSL_IN_RAM, OSL_PF_4BIT); //We can get the palette size with this (in our case it's 16, as 4 bits means 16 colors). int palSize = 1 << osl_paletteSizes[img->pixelFormat]; //Loop index variable. int i; //Palettes are not automatically created with images, we need to do it by yourself img->palette = oslCreatePaletteEx(palSize, OSL_IN_RAM, OSL_PF_8888); //Get a pointer to palette data u32 *paletteData = (u32*)img->palette->data; //Set all entries to bright opaque red. for (i=0;i<img->palette->nElements;i++) paletteData[i] = RGBA(255, 0, 0, 255); //Don't forget to uncache the palette after finished with it oslUncachePalette(img->palette); //An alternate possibility is: oslUncacheImage(img); (uncaches the palette as well)
| OSL_PALETTE* oslCreatePalette | ( | int | size, | |
| short | pixelFormat | |||
| ) | [inline] |
Creates a palette. Simpler function without the location argument.
| OSL_PALETTE* oslCreatePaletteFrom | ( | void * | data, | |
| int | size, | |||
| short | pixelFormat | |||
| ) |
Creates a palette from existing data. Please note that data is not copied to a new location but used as is! You just have to specify the palette size and pixelFormat.
| void oslDeletePalette | ( | OSL_PALETTE * | p | ) |
Deletes an existing palette. If the palette was created with oslCreatePaletteFrom, the data is not freed or anything, it's left as it was before, only the OSL_PALETTE structure is freed.
| int oslGetPaletteColor | ( | OSL_PALETTE * | p, | |
| int | index | |||
| ) |
Returns a color entry from a palette. The color will be in the same pixelformat as the palette (16 or 32 bits).
| void oslUncachePalette | ( | OSL_PALETTE * | pal | ) |
Uncaches a palette. As with oslUncacheData, always uncache a palette after you've accessed it in a cached way (pal->data). Look at oslCreatePalette for more info.
1.5.2